package com.ziyun.erp.web.modules.goodsCopyNew.controller;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.ziyun.erp.modules.goods.service.GoodsProductService;
import com.ziyun.erp.modules.goodsProductCopyNew.entity.GoodsProductCopyNewEntity;
import com.ziyun.erp.modules.goodsProductCopyNew.service.GoodsProductCopyNewService;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.goodsCopyNew.entity.GoodsCopyNewEntity;
import com.ziyun.erp.modules.goodsCopyNew.service.GoodsCopyNewService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 商品迁移临时表
 *
 * @author xueqz
 * @email 
 * @date 2018-10-15 11:43:18
 */
@RestController
@RequestMapping("goodsCopyNew/goodscopynew")
public class GoodsCopyNewController {
    @Autowired
    private GoodsCopyNewService goodsCopyNewService;

    @Autowired
    private GoodsProductCopyNewService goodsProductCopyNewService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("goodsCopyNew:goodscopynew:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = goodsCopyNewService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{goodsId}")
    @RequiresPermissions("goodsCopyNew:goodscopynew:info")
    public R info(@PathVariable("goodsId") Long goodsId){
        GoodsCopyNewEntity goodsCopyNew = goodsCopyNewService.selectById(goodsId);

        return R.ok().put("goodsCopyNew", goodsCopyNew);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("goodsCopyNew:goodscopynew:save")
    public R save(@RequestBody GoodsCopyNewEntity goodsCopyNew){
        goodsCopyNewService.insert(goodsCopyNew);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("goodsCopyNew:goodscopynew:update")
    public R update(@RequestBody GoodsCopyNewEntity goodsCopyNew){
        ValidatorUtils.validateEntity(goodsCopyNew);
        goodsCopyNewService.updateAllColumnById(goodsCopyNew);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("goodsCopyNew:goodscopynew:delete")
    public R delete(@RequestBody Long[] goodsIds){
        goodsCopyNewService.deleteBatchIds(Arrays.asList(goodsIds));

        return R.ok();
    }

//    /**
//     * 数据迁移
//     */
//    @RequestMapping("/dataMigration")
//    public R dataMigration(){
//        List<GoodsCopyNewEntity> goodsCopyNewList = goodsCopyNewService.dataMigration();
//        System.out.println("数据迁移");
//
//        return R.ok();
//    }


}
